#ifndef _AHCI_H_
#define _AHCI_H_
#include "basetype.h"

#define VIA_AHCI_VENDOR_ID 0x1106
#define VIA_AHCI_DEVICE_ID 0x0514

/*--------------------------- interface with host ----------------------------*/
#define SUB_DISK_CNT 3
#define SUB_DISK_A 0
#define SUB_DISK_B 1
#define SUB_DISK_C 2
#define FLASH_ADDR_CNT 8
#define MAX_CMD_SLOT 32

typedef enum _HOST_REQ_TYPE
{
    HOST_REQ_READ = 0,
    HOST_REQ_WRITE,
    HOST_REQ_ERASE,
    HOST_REQ_OTHER,
    HOST_REQ_INVALID
}HOST_REQ_TYPE;

typedef struct _SUB_DISK_CMD
{
    U32 DiskEn: 1;
    U32 ReqType: 2;
    U32 Dw0Rsvd: 5;
    U32 StartUnit: 24;//for diskA, unit means byte; for read/write diskB/C, means sector
    U32 UnitLength;// for erase in diskC, UnitLength means number of block to erase
    U32 HostAddrLow;
    U32 HostAddrHigh;
}SUB_DISK_CMD;

typedef union _FLASH_ADDR
{
    struct {
    U32 PU: 5;
    U32 Block: 11;
    U32 Page: 9;
    U32 Rsvd: 7;
    };
    U32 AsU32;
}FLASH_ADDR, *PFLASH_ADDR;

typedef struct _HOST_CMD
{
    SUB_DISK_CMD SubDiskCmd[SUB_DISK_CNT];

    FLASH_ADDR FlashAddrGroup[FLASH_ADDR_CNT];

    ULONG FinishCnt[SUB_DISK_CNT];
    
    UCHAR ErrFlag[ 4 ];
}HOST_CMD, *PHOST_CMD;

#endif // _AHCI_H_

